package etc;

import gui.Gui;
import gui.Guimap;
import gui.GuimapListener;
import gui.Selection;

import javax.swing.JFrame;

import network.NetworkLink;

import main.GameMaster;
import main.Logger;
import main.PlayerStats;
import main.TDMap;
import main.Ticker;

public class Main extends JFrame {
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		super("duper");
		Logger logg = new Logger();
		PlayerStats ps = new PlayerStats();
		ps.cash = 10000;
		ps.lives = 100;
		Ticker ticker = new Ticker();
		TDMap tdmap = new TDMap(Guimap.MAP_WIDTH, Guimap.MAP_HEIGHT, ticker);
		GameMaster gm = new GameMaster(tdmap, ticker, ps, logg);
		Guimap gmap = new Guimap(tdmap, gm.getEnemies());

		ticker.addPrio2(gmap);

		Selection s = new Selection();
		GuimapListener gmm = new GuimapListener(tdmap, gmap, s, ps);
		NetworkLink nl = new NetworkLink(tdmap);
		new Thread(nl).start();
		gmap.addMouseListener(gmm);
		this.addKeyListener(gmm);
		
		new Gui(gmap, s, ps, logg);
		tdmap.addObserver(gmap);
		
		new Thread(ticker).start();
	}
	
}
